import 'package:equatable/equatable.dart';
import 'package:backend.core/core/domain/entities/app_store/app_store_purchased_subscription_expiration_reason.dart';
import 'package:backend.core/core/domain/entities/app_store/app_store_purchased_subscription_price_increase_status.dart';

class AppStorePurchasedSubscriptionInfo extends Equatable {
  const AppStorePurchasedSubscriptionInfo({
    required this.appStoreUserId,
    required this.purchaseItemSku,
    required this.originalTransactionId,
    required this.autoRenewalEnabled,
    required this.isInBillingRetryPeriod,
    required this.priceIncreaseStatus,
    required this.test,
    required this.expirationReason,
    required this.gracePeriodExpirationTime,
  });

  final String appStoreUserId;
  final String purchaseItemSku;
  final String originalTransactionId;
  final bool autoRenewalEnabled;
  final bool isInBillingRetryPeriod;
  final AppStorePurchasedSubscriptionPriceIncreaseStatus priceIncreaseStatus;
  final bool test;
  final AppStorePurchasedSubscriptionExpirationReason? expirationReason;
  final DateTime? gracePeriodExpirationTime;

  @override
  List<Object?> get props {
    return [
      appStoreUserId,
      purchaseItemSku,
      originalTransactionId,
      autoRenewalEnabled,
      isInBillingRetryPeriod,
      priceIncreaseStatus,
      test,
      expirationReason,
      gracePeriodExpirationTime,
    ];
  }

  AppStorePurchasedSubscriptionInfo copyWith({
    String Function()? appStoreUserId,
    String Function()? purchaseItemSku,
    String Function()? originalTransactionId,
    bool Function()? autoRenewalEnabled,
    bool Function()? isInBillingRetryPeriod,
    AppStorePurchasedSubscriptionPriceIncreaseStatus Function()? priceIncreaseStatus,
    bool Function()? test,
    AppStorePurchasedSubscriptionExpirationReason? Function()? expirationReason,
    DateTime? Function()? gracePeriodExpirationTime,
  }) {
    return AppStorePurchasedSubscriptionInfo(
      appStoreUserId: appStoreUserId == null ? this.appStoreUserId : appStoreUserId(),
      purchaseItemSku: purchaseItemSku == null ? this.purchaseItemSku : purchaseItemSku(),
      originalTransactionId:
          originalTransactionId == null ? this.originalTransactionId : originalTransactionId(),
      autoRenewalEnabled:
          autoRenewalEnabled == null ? this.autoRenewalEnabled : autoRenewalEnabled(),
      isInBillingRetryPeriod:
          isInBillingRetryPeriod == null ? this.isInBillingRetryPeriod : isInBillingRetryPeriod(),
      priceIncreaseStatus:
          priceIncreaseStatus == null ? this.priceIncreaseStatus : priceIncreaseStatus(),
      test: test == null ? this.test : test(),
      expirationReason: expirationReason == null ? this.expirationReason : expirationReason(),
      gracePeriodExpirationTime: gracePeriodExpirationTime == null
          ? this.gracePeriodExpirationTime
          : gracePeriodExpirationTime(),
    );
  }
}
